From 095859f49a28b271e562bd3e3eba7204497c2105 Mon Sep 17 00:00:00 2001 From: Alex Williamson Date: Thu, 10 May 2007 15:55:22 -0600 Subject: [PATCH] [IA64] Implement XENMEM_machine_memory_map on ia64. This is necessary for kexec/kdump for xen/ia64. kexec-tools needs to know real machine's memory map. Signed-off-by: Isaku Yamahata --- .../arch/ia64/xen/xcom_hcall.c | 14 +++++++++ .../arch/ia64/xen/xcom_mini.c | 13 ++++++++ xen/arch/ia64/xen/mm.c | 31 +++++++++++++++++++ xen/include/public/arch-ia64.h | 15 +++++++++ 4 files changed, 73 insertions(+) diff --git a/linux-2.6-xen-sparse/arch/ia64/xen/xcom_hcall.c b/linux-2.6-xen-sparse/arch/ia64/xen/xcom_hcall.c index b14db04ee6..4c90b5b01e 100644 --- a/linux-2.6-xen-sparse/arch/ia64/xen/xcom_hcall.c +++ b/linux-2.6-xen-sparse/arch/ia64/xen/xcom_hcall.c @@ -226,6 +226,8 @@ xencomm_hypercall_memory_op(unsigned int cmd, void *arg) { XEN_GUEST_HANDLE(xen_pfn_t) extent_start_va[2]; xen_memory_reservation_t *xmr = NULL, *xme_in = NULL, *xme_out = NULL; + xen_memory_map_t *memmap = NULL; + XEN_GUEST_HANDLE(void) buffer; int rc; switch (cmd) { @@ -254,6 +256,14 @@ xencomm_hypercall_memory_op(unsigned int cmd, void *arg) (&((xen_memory_exchange_t *)arg)->out); break; + case XENMEM_machine_memory_map: + memmap = (xen_memory_map_t *)arg; + xen_guest_handle(buffer) = xen_guest_handle(memmap->buffer); + set_xen_guest_handle(memmap->buffer, + (void *)xencomm_create_inline( + xen_guest_handle(memmap->buffer))); + break; + default: printk("%s: unknown memory op %d\n", __func__, cmd); return -ENOSYS; @@ -275,6 +285,10 @@ xencomm_hypercall_memory_op(unsigned int cmd, void *arg) xen_guest_handle(xme_out->extent_start) = xen_guest_handle(extent_start_va[1]); break; + + case XENMEM_machine_memory_map: + xen_guest_handle(memmap->buffer) = xen_guest_handle(buffer); + break; } return rc; diff --git a/linux-2.6-xen-sparse/arch/ia64/xen/xcom_mini.c b/linux-2.6-xen-sparse/arch/ia64/xen/xcom_mini.c index dd45ce943c..3c0baff1f0 100644 --- a/linux-2.6-xen-sparse/arch/ia64/xen/xcom_mini.c +++ b/linux-2.6-xen-sparse/arch/ia64/xen/xcom_mini.c @@ -238,6 +238,19 @@ xencomm_mini_hypercall_memory_op(unsigned int cmd, void *arg) argsize = sizeof (xen_add_to_physmap_t); break; + case XENMEM_machine_memory_map: + { + xen_memory_map_t *memmap = (xen_memory_map_t *)arg; + argsize = sizeof(*memmap); + rc = xencomm_create_mini(xc_area, &nbr_area, + xen_guest_handle(memmap->buffer), + memmap->nr_entries, &desc); + if (rc) + return rc; + set_xen_guest_handle(memmap->buffer, (void *)desc); + break; + } + default: printk("%s: unknown mini memory op %d\n", __func__, cmd); return -ENOSYS; diff --git a/xen/arch/ia64/xen/mm.c b/xen/arch/ia64/xen/mm.c index 367ed5a0dd..753636e147 100644 --- a/xen/arch/ia64/xen/mm.c +++ b/xen/arch/ia64/xen/mm.c @@ -2145,6 +2145,37 @@ arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg) break; } + case XENMEM_machine_memory_map: + { + struct xen_memory_map memmap; + struct xen_ia64_memmap_info memmap_info; + XEN_GUEST_HANDLE(char) buffer; + + if (!IS_PRIV(current->domain)) + return -EINVAL; + if (copy_from_guest(&memmap, arg, 1)) + return -EFAULT; + if (memmap.nr_entries < + sizeof(memmap_info) + ia64_boot_param->efi_memmap_size) + return -EINVAL; + + memmap.nr_entries = + sizeof(memmap_info) + ia64_boot_param->efi_memmap_size; + memset(&memmap_info, 0, sizeof(memmap_info)); + memmap_info.efi_memmap_size = ia64_boot_param->efi_memmap_size; + memmap_info.efi_memdesc_size = ia64_boot_param->efi_memdesc_size; + memmap_info.efi_memdesc_version = ia64_boot_param->efi_memdesc_version; + + buffer = guest_handle_cast(memmap.buffer, char); + if (copy_to_guest(buffer, (char*)&memmap_info, sizeof(memmap_info)) || + copy_to_guest_offset(buffer, sizeof(memmap_info), + (char*)__va(ia64_boot_param->efi_memmap), + ia64_boot_param->efi_memmap_size) || + copy_to_guest(arg, &memmap, 1)) + return -EFAULT; + return 0; + } + default: return -ENOSYS; } diff --git a/xen/include/public/arch-ia64.h b/xen/include/public/arch-ia64.h index 9b27394da7..ac0bae0a7b 100644 --- a/xen/include/public/arch-ia64.h +++ b/xen/include/public/arch-ia64.h @@ -317,6 +317,21 @@ struct arch_vcpu_info { }; typedef struct arch_vcpu_info arch_vcpu_info_t; +/* + * This structure is used for magic page in domain pseudo physical address + * space and the result of XENMEM_machine_memory_map. + * As the XENMEM_machine_memory_map result, + * xen_memory_map::nr_entries indicates the size in bytes + * including struct xen_ia64_memmap_info. Not the number of entries. + */ +struct xen_ia64_memmap_info { + uint64_t efi_memmap_size; /* size of EFI memory map */ + uint64_t efi_memdesc_size; /* size of an EFI memory map descriptor */ + uint32_t efi_memdesc_version; /* memory descriptor version */ + void *memdesc[0]; /* array of efi_memory_desc_t */ +}; +typedef struct xen_ia64_memmap_info xen_ia64_memmap_info_t; + struct arch_shared_info { /* PFN of the start_info page. */ unsigned long start_info_pfn; -- 2.30.2